package com.su.test;

import java.util.Arrays;

public class Node implements Comparable<Node> {
    int num[];                      //八数码
    int depth;                      //当前的深度
    int evaluation;                 //评估值 = 深度 + 不在位的个数
    int misposition;                //节点“不在位”的数码个数
    int emptyIndex;                 //空格的位置
    Node parent;                    //父节点

    public Node() {
    }

    public Node(int []num,int emptyIndex, Node parent){     //针对BFS
        this.num = num;
        this.emptyIndex = emptyIndex;
        this.parent = parent;
    }

    public Node(int []num,int emptyIndex,Node parent,int depth){     //针对DFS
        this.num = num;
        this.emptyIndex = emptyIndex;
        this.parent = parent;
        this.depth = depth;
    }

    public Node(int[] num, int misposition, int emptyIndex, Node parent) {
        this.num = num;
        this.misposition = misposition;
        this.emptyIndex = emptyIndex;
        this.parent = parent;
        if(parent == null)
            depth = 0;
        else
            depth = parent.depth + 1;
        this.evaluation = this.depth + this.misposition;
    }

    @Override
    public int compareTo(Node o) {
        if(Arrays.equals(num,o.num))
            return 0;
        return -1;
    }
}
